package gptma.bo.model.application;

import gptma.bo.model.BaseEntity;

import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "application")
@AttributeOverride(name = "id", column = @Column(name = "applicationId"))
public class Application extends BaseEntity {

	private static final long serialVersionUID = -8762845188055351720L;

	@Column(name = "nom")
	private String name;

	@Column(name = "description")
	private String description;

	@OneToOne
	@JoinColumn(name = "groupeApplicationId")
	private ApplicationGroup group;

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinTable(name = "composantApplication", joinColumns = { @JoinColumn(referencedColumnName = "applicationId") })
	private List<ApplicationComponent> components;

	@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "versionApplication", joinColumns = { @JoinColumn(referencedColumnName = "applicationId") })
	private List<ApplicationVersion> versions;

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description
	 *            the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the group
	 */
	public ApplicationGroup getGroup() {
		return group;
	}

	/**
	 * @param group
	 *            the group to set
	 */
	public void setGroup(ApplicationGroup group) {
		this.group = group;
	}

	/**
	 * @return the components
	 */
	public List<ApplicationComponent> getComponents() {
		return components;
	}

	/**
	 * @param components
	 *            the components to set
	 */
	public void setComponents(List<ApplicationComponent> components) {
		this.components = components;
	}

	/**
	 * @return the versions
	 */
	public List<ApplicationVersion> getVersions() {
		return versions;
	}

	/**
	 * @param versions
	 *            the versions to set
	 */
	public void setVersions(List<ApplicationVersion> versions) {
		this.versions = versions;
	}

}
